//c5
using System;

public delegate void TickHandler(object sender, TickArgs e);

public class TickArgs : EventArgs
{
    public int CurrentTime { get; set; }
}

public class AlarmClock
{
    public event TickHandler Tick;
    public event EventHandler Alarm;

    private int alarmTime;

    public void SetAlarm(int time)
    {
        alarmTime = time;
        Console.WriteLine("闹钟已设置为:" + alarmTime);
    }

    public void Start(int currentTime)
    {
        Console.WriteLine("闹钟开始运行...");

        while (true)
        {
            TickArgs tickArgs = new TickArgs { CurrentTime = currentTime };
            Tick(this, tickArgs);
            if (currentTime == alarmTime)
            {
                Alarm(this, EventArgs.Empty);
                break;
            }
            currentTime++;
        }
    }
}

class Program
{
    static void Main()
    {
        AlarmClock clock = new AlarmClock();
        clock.Tick += (sender, e) => Console.WriteLine($"嘀嗒: {e.CurrentTime}");
        clock.Alarm += (sender, e) => Console.WriteLine("闹铃响了！时间到了！");
        clock.SetAlarm(10);
        clock.Start(0);
    }
}